﻿Imports MySql.Data
Imports MySql.Data.MySqlClient

Public Class Conexion
    Private Shared cadena As String = "server=localhost;user=root;database=sim;password=800825ers;"
    Public Shared BdSim As MySqlConnection
    Public Shared Function open() As MySqlConnection
        Try
            BdSim = New MySqlConnection(cadena)
            BdSim.Open()
        Catch ex As Exception
            Close(BdSim)
            MsgBox(ex.ToString())
        End Try
        Return BdSim
    End Function
    Public Shared Sub Close(ByVal Bdsim As MySqlConnection)
        If Bdsim.State = ConnectionState.Open Then
            Try
                Bdsim.Close()
                Bdsim = Nothing
            Catch ex As Exception
                MsgBox("Error" & ex.ToString)
            End Try
        End If
    End Sub
End Class
